#include<iostream>
#include<vector>
using namespace std;
class Solution {
    string path;
    vector<string> ret;

public:
    vector<string> letterCasePermutation(string s) {
        dfs(s, 0);
        return ret;
    }
    char change(char ch) {
        if (ch >= 'a' && ch <= 'z') return ch - 32;
        else return ch + 32;
    }
    void dfs(string& s, int pos) {
        if (path.size() == s.size()) {
            ret.push_back(path);
            return;
        }

        if (isalpha(s[pos])) {
            path += s[pos];
            dfs(s, pos + 1);
            path.pop_back();

            path += change(s[pos]);
            dfs(s, pos + 1);
            path.pop_back();

        }
        else {
            path += s[pos];
            dfs(s, pos + 1);
            path.pop_back();
        }
    }

}
;